<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">


    <table class="table table-striped">
        <thead>
        <tr>
            <th width="100" style="color:red">{:__('OA流转设置')}</th>
            <!--<th>{:__('Content')}</th>-->
        </tr>
        </thead>
        <tbody>

        {if condition="$count == 0"}
        <tr>
            <td>
                <div class="form-group">
                    <label for="c-ids" class="control-label col-xs-12 col-sm-2"><span style="color: red;font-size: 15px">*</span>{:__('默认审批')}:</label>
                    <div class="col-xs-12 col-sm-8">
                        <select id="c-ids" data-rule="required" data-live-search="true" class="form-control selectpicker" name="row[ids][0]">
                            <option value="0"></option>
                            {foreach $arr as $index=>$vo}
                            <option value="{$vo.id}">{$vo.nickname}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
            </td>
        </tr>
        {else}
        {foreach $oa as $k=>$v}
        <tr>
            <td>
                <div class="form-group">
                    <label for="c-ids-{$k}" class="control-label col-xs-12 col-sm-2"><span style="color: red;font-size: 15px">*</span>{if condition="$k != 0"}{:__('下级审批')}:{else}{:__('默认审批')}:{/if}</label>
                    <div class="col-xs-12 col-sm-8">
                        <select id="c-ids-{$k}" data-rule="required" data-live-search="true" class="form-control selectpicker" name="row[ids][{$k}]">
                            <option value="0"></option>
                            {foreach $arr as $index=>$vo}
                            <option value="{$vo.id}" {if condition="$v.admin_id==$vo.id"}selected{/if}>{$vo.nickname}</option>
                            {/foreach}
                        </select>
                    </div>
                    {if condition="$k != 0"}
                    <input class="btn btn-sm btn-danger btn-remove" type="button" onclick="news23(this)" id="news" value="删除" />
                    {/if}
                </div>
            </td>
        </tr>
        {/foreach}
        {/if}

        <input class="btn btn-sm btn-success btn-append" type="button" id="new" value="新增" />
        </tbody>
    </table>
    <input  type="hidden" name="row[id]"  value="{$row->id}" />
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>

<script src="/assets/img/jquery-3.4.1.min.js"></script>
<script>
    var x = {$count};
    $("#new").off("click").on("click",function(){
        //$('#new').click(function(){
        x=x+1;
        console.log(x);
        let html = `<tr>
            <td>
                <div class="form-group">
                    <label for="c-ids" class="control-label col-xs-12 col-sm-2"><span style="color: red;font-size: 15px">*</span>{:__('下级审批')}:</label>
                    <div class="col-xs-12 col-sm-8">
                        <select id="c-ids-`+x+`" data-rule="required" data-live-search="true" class="form-control selectpicker" name="row[ids][`+x+`]">
                            <option value="0"></option>
                            {foreach $arr as $index=>$vo}
                            <option value="{$vo.id}">{$vo.nickname}</option>
                            {/foreach}
                        </select>
                    </div>
                    <input class="btn btn-sm btn-danger btn-remove" type="button" onclick="news23(this)" id="news" value="删除" />
                </div>
            </td>
        </tr>`;
        $(".table-striped").append(html)
    });
    function news23(that){
        $(that).parents("tr").remove();//指定tr元素

    }

</script>
